<template>
  <div id="chartContainers" style="width: 100%; height: 400px;"></div>
</template>

<script>
import echarts from "echarts";
import axios from "axios";

export default {
  data() {
    return {
      xAxisData: ['12:00', '12:30', '13:00', '13:30', '14:00', '14:30', '15:00', '15:30', '16:00', '16:30', '17:00', '17:30', '18:00', '18:30', '19:00', '19:30', '20:00', '20:30', '21:00', '21:30', '22:00', '22:30', '23:00', '23:30', '24:00'],
      seriesData: []
    };
  },
  mounted() {
    // 基于准备好的dom，初始化echarts实例
    this.getData();
  },
  methods: {
    getData(){
      axios.get("http://localhost:9999/api-cockpit/orders/getDataAfternoon").then(res=>{
        this.seriesData = res.data.data;
        console.log(this.seriesData)
        this.echartsInit();
      })

    },
    echartsInit(){
      console.log("seriesData",this.seriesData)
      // 基于准备好的dom，初始化echarts实例
      let myChart = echarts.init(document.getElementById('chartContainers'));

      // 绘制图表
      myChart.setOption({
        xAxis: {
          type: 'category',
          data: this.xAxisData
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            type: 'line',
            areaStyle: {},
            data: this.seriesData
          }
        ]
      });
      console.log("seriesData2",this.seriesData)
    }
  }
}
</script>
